import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TheadExecutor {
    @Test
   void test1() {
        // 创建固定大小的线程池
        ExecutorService executor = Executors.newFixedThreadPool(10);

// 提交任务
        for (int i = 0; i < 10; i++) {
            executor.submit(() -> {
                // 执行任务
                System.out.println("Task executed by: " + Thread.currentThread().getName());
            });
        }

// 关闭线程池
        executor.shutdown();

    }
    @Test
    void test2(){

        try {
            System.out.println(0);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }finally {
            System.out.println(2);
        }

    }
}
